<?php
class LypoResult {
	
	var $error = false;
	var $message = "";
	var $data = array();
	var $html = '';
	
	public function toArray(){
		$result = Array();
		$result['error']=$this->hasError();
		$result['message']=$this->getMessage();
		$result['data']= $this->data;
		if($this->html) $result['html']= $this->html;
		return $result;
	} 
	
	public function hasMessage(){
		return ($this->message != '');
	}
	
	public function hasError(){
		return ($this->error === true);
	}
	
	function setData($key,$val){
		$this->data[$key]=$val;
	}
	
	function setHtml($key,$val){
		$this->html[$key]=$val;
	}
	
	public function getMessage(){
		return $this->message;
	}
	
	public function setErrorMessage($msg){
		$this->error = true;
		$this->message = $msg;
	}
	
	public function setMessage($msg){
		$this->message = $msg;
	}
	
	public function toJSON(){
		return json_encode($this->toArray());
	}
	
}
?>